//
// Created by 谢哲 on 2021/5/19.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


int main() {
    int n, m;
    cin >> n >> m;

    vector<long long> cf_data(n, 0ll);
    int last_p = -1;
    for (int i=0; i<m; ++i) {
        int p;
        cin >> p;
        --p;
        if (last_p>=0) {
            cf_data[min(last_p, p)]++;
            cf_data[max(last_p, p)]--;
        }
        last_p = p;
    }

    long long ans = 0ll;
    long long cnt = 0ll;
    for (int i=0;i<n-1;++i) {
        long long a, b, c;
        cin >> a >> b >> c;
        cnt += cf_data[i];
        ans += min(cnt * a, c + cnt * b);
    }
    cout << ans;

    return 0;
}